package com.mall.controller.admin;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mall.entity.OrderDetail;
import com.mall.entity.R;
import com.mall.service.IOrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/orderDetail")
public class AdminOrderDetailController {

    @Autowired
    private IOrderDetailService orderDetailService;

    @RequestMapping("/list/{id}")
    public R listByOrderId(@PathVariable(value = "id") Integer id) {
        List<OrderDetail> orderDetailList = orderDetailService
                .list(new LambdaQueryWrapper<OrderDetail>().eq(OrderDetail::getMId, id));
        Map<String, Object> map = new HashMap<>();
        map.put("list", orderDetailList);
        return R.ok(map);
    }
}
